package com.headfirst.BehaviorMode.command.remote.version1;

import com.headfirst.BehaviorMode.command.remote.version1.equipment.CeilingFan;
import com.headfirst.BehaviorMode.command.remote.version1.equipment.GarageDoor;
import com.headfirst.BehaviorMode.command.remote.version1.equipment.Light;
import com.headfirst.BehaviorMode.command.remote.version1.equipment.Stereo;

public class RemoteLoader {

    public static void main(String[] args) {
        
        // 得到遥控器类对象
        RemoteControl remoteControl = new RemoteControl();

        // 在合适的位置创建装置
        Light livingRoomLight = new Light("Living Room");
        Light kitchenLight = new Light("Kitchen");
        CeilingFan ceilingFan = new CeilingFan("Living Room");
        GarageDoor garageDoor = new GarageDoor("Garage");
        Stereo stereo = new Stereo("Living Room");
        
        // 创建电灯命令对象
        LightOnCommand livingRoomLightOn = new LightOnCommand(livingRoomLight);
        LightOffCommand livingRoomLightOff = new LightOffCommand(livingRoomLight);
        LightOnCommand kitchenLightOn = new LightOnCommand(kitchenLight);
        LightOffCommand kitchenLightOff = new LightOffCommand(kitchenLight);
        
        // 创建吊扇的开与关的命令对象
        CeilingFanOnCommand ceilingFanOnCommand = new CeilingFanOnCommand(ceilingFan);
        CeilingFanOffCommand ceilingFanOffCommand = new CeilingFanOffCommand(ceilingFan);
        
        // 创建车库门的上与下命令对象
        GarageDoorUpCommand garageDoorUpCommand = new GarageDoorUpCommand(garageDoor);
        GarageDoorDownCommand garageDoorDownCommand = new GarageDoorDownCommand(garageDoor);
        
        // 创建音响的开与关命令
        StereoOnWithCDCommand stereoOnWithCDCommand = new StereoOnWithCDCommand(stereo);
        StereoOffCommand stereoOffCommand = new StereoOffCommand(stereo);
        
        // 把所有的命令加载到遥控器的插槽中
        remoteControl.setCommands(0, livingRoomLightOn, livingRoomLightOff);
        remoteControl.setCommands(1, kitchenLightOn, kitchenLightOff);
        remoteControl.setCommands(2, ceilingFanOnCommand, ceilingFanOffCommand);
        remoteControl.setCommands(3, garageDoorUpCommand, garageDoorDownCommand);
        remoteControl.setCommands(4, stereoOnWithCDCommand, stereoOffCommand);

        System.out.println(remoteControl);
        
        remoteControl.onButtonWasPushed(0);
        remoteControl.offButtonWasPushed(0);
        remoteControl.onButtonWasPushed(1);
        remoteControl.offButtonWasPushed(1);
        remoteControl.onButtonWasPushed(2);
        remoteControl.offButtonWasPushed(2);
        remoteControl.onButtonWasPushed(3);
        remoteControl.offButtonWasPushed(3);
        remoteControl.onButtonWasPushed(4);
        remoteControl.offButtonWasPushed(4);
        
        
        
    }
}
